function initCourseInit(danceList, levles, nature) {
  var obj = {
    tabList: [{
      cascadeActive: 0,
      templete: "cascade",
      name: "舞蹈",
      code: "dance",
      active: true,
      cascadeObj: [{
        name: "全舞种",
        active: true,
        subList: [{
          name: "全部",
          code: "all",
          active: true
        }]
      }]
    },{
      name: "课程类别",
      code: "level",
      active: false,
      templete: "list-sort",
      cascadeObj: [{
        name: "全部",
        code: "all",
        active: true
      }]
    },{
      name: "课程性质",
      code: "type",
      active: false,
      templete: "list-sort",
      cascadeObj: [{
        name: "全部",
        code: "all",
        active: true
      }]
    }],
    activeIndex: 0
  }
  danceList.map(item => {
    var temp1 = {
      name: item.showValue,
      active: false,
      subList: [{
        name: "全部",
        code: "all",
        active: true
      }]
    }
    item.children.map(el => {
      var temp2 = {
        name: el.showValue,
        code: el.dictValue,
        active: false
      }
      obj.tabList[0].cascadeObj[0].subList.push(temp2);
      temp1.subList.push(temp2);
    });
    obj.tabList[0].cascadeObj.push(temp1);
  })

  levles.map(item => {
    var temp = {
      name: item.showValue,
      code: item.dictValue,
      active: false
    }
    obj.tabList[1].cascadeObj.push(temp);
  });
  nature.map(item => {
    var temp = {
      name: item.showValue,
      code: item.dictValue,
      active: false
    }
    obj.tabList[2].cascadeObj.push(temp);
  });
  return obj;
}
function getDanceKindParam(danceList) {
  var danceKind = []
  if(danceList[0].active){
    if(!danceList[0].subList[0].active) {
      danceList[0].subList.map(item => {
        if(item.active) {
          danceKind.push(item.code)
        }
      })
    }
  }else {
    danceList.map(item => {
      if(item.active) {
        if(item.subList[0].active) {
          //选择全部
          for(var i = 1;i<item.subList.length;i++) {
            danceKind.push(item.subList[i].code)
          }
        } else {
          //选择部分
          item.subList.map(el => {
            if(el.active) {
              danceKind.push(el.code)
            }
          })
        }
      }
    })
  }
  return danceKind;
}

function getCourseParam(tabList) {
  var param = {
    danceKind: [],
    courseLevel: [],
    courseNature: []
  }
  // 获取舞蹈种类
  var danceList = tabList[0].cascadeObj;
  param.danceKind = getDanceKindParam(danceList);

  // 获取课程等级
  var levelList = tabList[1].cascadeObj;
  if (!levelList[0].active) {
    levelList.map(item => {
      if(item.active){
        param.courseLevel.push(item.code);
      }
    })
  }
  // 课程性质
  var natureList = tabList[2].cascadeObj;
  if (!natureList[0].active) {
    natureList.map(item => {
      if(item.active) {
        param.courseNature.push(item.code)
      }
    })
  }
  return param;
}

module.exports = {
  initCourseInit,
  getCourseParam,
  getDanceKindParam
}